﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GLYFrom.tcgl
{
    public partial class tc_insert : Form
    {
        public tc_insert()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string Name = this.text_Name.Text.Trim();
            string JiaGe = this.text_JG.Text.Trim();
            string XiangXi = this.text_XX.Text.Trim();
            DataTable table = DBHelper.select("select * from T_TaoCan");
            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataRow row = table.Rows[i];
                string name=row["TCName"].ToString();
                if (Name==name)
                {
                    MessageBox.Show("添加失败,套餐以存在！");
                    return;
                }
            }
            if (Name.Length>0 && JiaGe.Length>0 && XiangXi.Length>0)
            {
                int sr = DBHelper.ZSG(string.Format("insert into T_TaoCan values('{0}','{1}','{2}')", Name, XiangXi, JiaGe));
                if (sr > 0)
                {
                    MessageBox.Show("添加成功！");
                }
                else
                {
                    MessageBox.Show("添加失败！");
                }
            }
            else
            {
                MessageBox.Show("添加失败,请填写完整！");
                return;
            }
            
        }
    }
}
